<template>
  <div id="category" class="category">
    <el-row>
      <el-col :span="24">
         <div class="panel">
            <div class="panel-header">
              <h3 class="title">商品分类<el-button type="primary" class="fr postbtn"><router-link :to="{ name: 'addCategory'}">添加分类</router-link></el-button></h3>
            </div>
            <div class="panel-content">
              <table class="table-common-main-lang mlr10 tl" cellpadding="0" cellspacing="0">
                <thead>
                  <tr>
                    <th v-for="item in tableData.tHead" class="tl">
                      <strong>{{ item }}</strong>
                    </th>  
                  </tr>
                </thead>
                <tbody>
                  <tr v-for="item in tableData.tDataList">
                    <td>{{ item.id }}</td>
                    <td>{{ item.name }}</td>
                    <td><router-link :to="{ name: 'categorydetail', params: { id: item.id, categoryName: item.name }}" class="opr modify">修改名称</router-link><span class="opr"></span><span class="opr">查看子品类</span></td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import axios from 'axios'
  export default{
    name: 'newsForm',
    data () {
      return {
        tableData: {
          tHead: [
            '品类ID',
            '品类名称',
            '操作'
          ],
          tDataList: ''
        },
        value: '',
        goodsType: [
          {
            value: 0,
            label: '选择全部'
          },
          {
            value: 1,
            label: '分类一'
          },
          {
            value: 2,
            label: '分类二'
          }
        ],
        goodlist: {
          pageNum: 1,
          pageSize: 10
        }
      }
    },
    components: {
    },
    created () {
      axios({
          url: 'http://47.90.38.178:8080/wx_shop_test/manage/category/get_category.do',
          method: 'POST',
          params: this.goodlist
        }).then(obj => {
          console.log(obj)
          if (obj.data.status === 0) {
            console.log('x')
            this.tableData.tDataList = obj.data.data
            console.log(this.tableData.tDataList)
          }
        })
    },
    methods: {
      contactUrl (host, str) {
        return host + str
      },
      modify () {

      },
      openDetail (id) {
        this.$router.push('/goodsdetail/' + id)
      }
    }
  }
</script>
<style>
  .dashboard .el-row{
    margin-bottom: 30px;
  }
  .portlets{
    margin-bottom: 10px;
  }
  .thumbIndex{
    width: 80px;
    height: 80px;
    float: left;
  }
  .goodsall .productInfo{
    margin: 0 10px;
  }
  .goodsall .title{ 
    margin-left: 90px;
    text-align: left;
    max-width: 240px; 
  }
  .opr{
    padding: 0 8px;
  }
  .modify{

  }
</style>
